﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SubSystem.Models.ObjectStore;

namespace SubSystem.Models
{
    public class ArticleModel
    {
        private ObjectManager<IArticle> manager;
        
        private List<IArticle> articles;

        public ArticleModel(ObjectManager<IArticle> objectManager)
        {
            manager = objectManager;
        }

        public List<IArticle> Articles
        {
            get
            {
                if (articles == null)
                {
                    articles = manager.Fetch().ToList();
                }

                return articles;
            }
            
            set
            {
                articles = value;
            }
        }

        public IArticle Article { get; set; }

        public IEnumerable<Image> Images
        {
            get { return new List<Image>
                         {
                             new Image
                                 {
                                     Source = @"/Content/Images/Craftsman.jpg",
                                     Class = "TitleImage",
                                     Alt = "Software Craftsman"
                                 },

                             new Image
                                 {
                                     Source = @"/Content/Images/Father.jpg",
                                     Class = "TitleImage",
                                     Alt = "Husband & father"
                                 }
                            }; }
        }
    }
}
